﻿using System;
using XC.DataAccess.EncoderDecoder.Services;

namespace Microsoft.Extensions.DependencyInjection
{
    /// <summary>
    /// 应用程序扩展
    /// </summary>
    public static class ApplicationExtension
    {
        /// <summary>
        /// 添加编码解码服务
        /// </summary>
        /// <param name="serviceDescriptors"></param>
        /// <returns></returns>
        public static IServiceCollection AddEncodingDecodingService(this IServiceCollection serviceDescriptors)
        {
            serviceDescriptors.AddSingleton<IFrameEncodeService, FrameEncodeService>();
            return serviceDescriptors;
        }
        /// <summary>
        /// 获取编码编码服务
        /// </summary>
        /// <param name="service"></param>
        /// <returns></returns>
        public static IFrameEncodeService? GetFrameEncodeService(this IServiceProvider service)
        {
            return service.GetService<IFrameEncodeService>();
        }
        /// <summary>
        /// 获取包解码服务
        /// </summary>
        /// <param name="serviceProvider"></param>
        /// <returns></returns>
        public static IFrameDecodeService? GetFrameDecodeService(this IServiceProvider serviceProvider)
        {
            return serviceProvider.GetService<IFrameDecodeService>();
        }
    }
}
